package stu.day39_day.day43;

import java.util.Scanner;

public class hw2 {

    public static int fun1(int[] arr,int m){
        int n = arr.length;
        int[][] dp = new int[n+1][m+1];

        for (int i = 0; i <= n; i++) {
            dp[i][0] = 1;
        }

        for(int i=1;i<=n;i++){
            for(int j=0;j<=m;j++){
                if(arr[i-1]>j){
                    dp[i][j] = dp[i-1][j];
                }else{
                    dp[i][j] = dp[i-1][j]+dp[i-1][j-arr[i-1]];
                }
            }
        }
        return dp[n][m];
    }





    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);


        String[] str = sc.nextLine().split(",");
        int n = str.length;

        int[] arr = new int[n];
        for (int i = 0; i < n; i++) {
            arr[i] = Integer.parseInt(str[i]);
        }

        int m =  Integer.parseInt(sc.nextLine());

        System.out.println(fun1(arr,m));

    }
}
